public class RandomNumber {
    public static void main(String[] args) {
        double randNum = 0;

        while (randNum < 0.5) {
            randNum = Math.random();
            System.out.println(randNum);
        }
        System.out.println(randNum);

        int rangeStart = 30;
        int rangeEnd = 90;

        if (rangeStart < 0 || rangeEnd < 0) {
            System.out.println("非法数字范围");
        }

        int mod = rangeEnd - rangeStart;
        if (mod <= 1) {
            System.out.println("非法的数字范围");
        }
        for (int i = 0; i < 50; i++) {
            int bigRandom = (int) (Math.random() * rangeEnd * 100);
            int numberToGuess = (bigRandom % mod) + rangeStart;

            if (numberToGuess <= rangeStart) {
                numberToGuess = rangeStart + 1;
            } else if (numberToGuess >= rangeEnd) {
                numberToGuess = rangeEnd - 1;
            }

            System.out.println("mod = " + mod + "，numberToGuess" + numberToGuess);
        }
    }
}
